package com.yuanfeng.payment.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yuanfeng.commoms.dto.order.RefundParamDTO;
import com.yuanfeng.commoms.dto.payment.AccountPeriodParamDTO;
import com.yuanfeng.commoms.dto.payment.GroupBookingParamDTO;
import com.yuanfeng.commoms.dto.payment.GroupBookingTradeDTO;
import com.yuanfeng.commoms.dto.payment.RefundAccountParamDTO;
import com.yuanfeng.commoms.dto.shop.ShopSalesStatisticsDTO;
import com.yuanfeng.commoms.vo.order.OrderBaseVO;
import com.yuanfeng.commoms.vo.payment.AccountShopBillDetailsVO;
import com.yuanfeng.commoms.vo.shop.AccountPeriodVO;
import com.yuanfeng.payment.dto.FinancialDetailsDTO;
import com.yuanfeng.payment.dto.PayConsumeRecordDTO;
import com.yuanfeng.payment.entity.PayConsumeRecordEntity;
import com.yuanfeng.payment.vo.ComsumeRecordParaVO;
import com.yuanfeng.payment.vo.ComsumeRecordVO;
import com.yuanfeng.payment.vo.QueryGoodsVO;
import com.yuanfeng.payment.vo.RecordVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * @ClassName PayConsumeRecordMapper
 * @Description  交易明细表-账户收支明细-资金流水表-账户金额变化流水
 * @Author cyp
 * @Date 2023-05-31 15:36:55
 * @Version 1.0
 **/
@Mapper
public interface PayConsumeRecordMapper extends BaseMapper<PayConsumeRecordEntity> {


    boolean insertConsumeRecordToSeller(@Param("paymentNumber") String paymentNumber,
                                        @Param("sellerId") String sellerId, @Param("userName") String userName,
                                        @Param("paymentAmout") BigDecimal paymentAmout, @Param("tradeDate") String tradeDate,
                                        @Param("tradeYear") String tradeYear, @Param("tradeMonth") String tradeMonth,
                                        @Param("tradeDay") String tradeDay, @Param("tradeTitle") String tradeTitle,
                                        @Param("tradeDesc") String tradeDesc, @Param("recordTime") String recordTime,
                                        @Param("tradeTypeId") Integer tradeTypeId, @Param("userType") Integer userType,
                                        @Param("recordStatus") Integer recordStatus, @Param("recordPayorderId") String recordPayorderId,@Param("isCurrentUser") Integer isCurrentUser);

    boolean insertBuyUserConsumeRecord(@Param("paymentNumber") String paymentNumber, @Param("userId") String userId,
                                       @Param("userName") String userName, @Param("paymentAmout") BigDecimal paymentAmout,
                                       @Param("tradeDate") String tradeDate, @Param("tradeYear") String tradeYear,
                                       @Param("tradeMonth") String tradeMonth, @Param("tradeDay") String tradeDay,
                                       @Param("tradeTitle") String tradeTitle, @Param("tradeDesc") String tradeDesc,
                                       @Param("recordTime") String recordTime, @Param("tradeTypeId") Integer tradeTypeId,
                                       @Param("userType") Integer userType, @Param("recordStatus") Integer recordStatus,
                                       @Param("recordPayorderId") String recordPayorderId,@Param("isCurrentUser")Integer isCurrentUser);

    /**
     * 新增信息
     *
     * @param map
     * @return
     */
    Integer insertRecord(Map<String, String> map);


    List<ComsumeRecordParaVO> queryRecentDealRecord(@Param("userId") String userId,
                                                    @Param("tradeTypeId") Integer tradeTypeId);

    String queryRefundOrderNum(String orderId);

    /**
     * 删除交易记录
     * @param userId
     * @param recordId
     */
    void updateRecordDelete(@Param("userId")String userId, @Param("recordId")Integer recordId);

    /**
     * 新增消费信息
     *
     * @param mapRecord
     * @return
     */
    boolean insertConsumeRecord(Map<String, Object> mapRecord);


    /**
     * 更新
     *
     * @param map
     * @return
     */
    Integer updateRecordRefuse(Map<String, String> map);

    /**
     * 查询用户信息
     */
   Map<String,Object> queryBuyUserId(@Param("orderId") String orderId);

    /**
     * 查询订单金额及订单名称
     *
     * @param orderId
     * @return
     */
    QueryGoodsVO queryGoodsPriceAndName(@Param("orderId") String orderId, @Param("userId") String userId);

    /**
     * 修改record状态(纯数字订单)
     */
   boolean updateRecordByInt(Map<String, Object> mapRecord);

    /**
     * 修改商家record状态(纯数字订单)
     */
   boolean updateRecordBySellerInt(@Param("orderId") String orderId, @Param("paymentTime") String paymentTime);

    /**
     * 修改record状态(非纯数字订单)
     */
    boolean updateRecord(Map<String, Object> mapRecord);

    /**
     * record表卖家更新(非纯数字订单)
     */
    boolean updateRecordBySeller(@Param("orderId") String orderId, @Param("paymentTime") String paymentTime);

    /**
     * 根据商户订单号查询
     *
     * @param orderId
     * @return
     */
    List<RecordVO> queryRecordParaList(@Param("orderId") String orderId);

    /**
     * 更新消费信息
     *
     * @param mapPureDigital
     * @return
     */
    boolean updateComsumeRecordByPureDigital(Map<String, Object> mapPureDigital);

    /**
     * 查询状态
     *
     * @param outTradeNo
     * @return
     */
    List<Integer> queryRecodeStatus(@Param("outTradeNo") String outTradeNo);

    /**
     * 查询订单
     *
     * @param outTradeNo
     * @return
     */
    List<ComsumeRecordVO> queryorderNo(@Param("orderId") String outTradeNo);

    /**
     * 更新消费
     *
     * @param mapPureDigital
     * @return
     */
    boolean updateComsumeRecord(Map<String, Object> mapPureDigital);

    /**
     * 查询信息
     *
     * @param orderId
     * @return
     */
    RecordVO queryRecordPara(@Param("orderId") String orderId);

    /**
     * 查询商品订单号与订单金额
     *
     * @param outTradeNo
     * @return
     */
    List<PayConsumeRecordDTO> queryOrderNo(String outTradeNo);

    /**
     * 查询订单状态
     *
     * @param outTradeNo
     * @return
     */
    List<Integer> queryAllRecordStatus(@Param("orderId") String outTradeNo);

    /**
     * 查询实际支付单号
     *
     * @param orderId
     * @return
     */
    List<String> queryPayOrderId(@Param("orderId") String orderId);

    /**
     * 查询状态
     *
     * @param orderId
     * @param userId
     * @return
     */
    List<Integer> queryStatus(@Param("orderId") String orderId, @Param("userId") String userId);

    /**
     * 查询plus 会员订单是否支付成功
     * @param userId
     * @param plusOrder
     * @return
     */
    Integer queryplusorder(@Param("userId")String userId,@Param("plusOrder")String plusOrder);


    /**
     * 分页查询
     *
     * @param page
     * @param param
     * @return
     */
    IPage<ShopSalesStatisticsDTO> querySalesStatistics(IPage<ShopSalesStatisticsDTO> page, @Param("param") ShopSalesStatisticsDTO param);


    /**
     * 分页查询详情参数
     *
     * @param page
     * @param param
     * @return
     */
    IPage<PayConsumeRecordEntity> platformQueryDetails(IPage<PayConsumeRecordEntity> page, @Param("param") FinancialDetailsDTO param);

    /**
     * 查询订单信息
     * @param orderId
     * @return
     */
    OrderBaseVO queryOrderInfo(String orderId);


    /**
     * 新增消费端口
     *
     * @param comRecord
     */
    void insertConsumeRecordport(Map<String, Object> comRecord);


    /**
     * 更新订单记录结算
     *
     * @param list
     * @return
     */
    boolean updateOrderRecordSettlements(@Param("list") List<String> list);

    /**
     * 新增信息
     *
     * @param mapRecord
     * @return
     */
    boolean insertSettlementRecord(Map<String, Object> mapRecord);


    Map selectYfPayConfig(String paymentMode);


    List<GroupBookingParamDTO> queryRefundConsumeRecordMoney(@Param("orderId") String orderId);

    BigDecimal calculateAllOrderMoney(@Param("uOrderId") String uOrderId);

    BigDecimal queryAllTradePaymentRechargeCard(@Param("uOrderId") String uOrderId);

    GroupBookingTradeDTO queryRefundTrade(@Param("orderId") String orderId);

    boolean updateUserMoneyResource(@Param("userId") String userId, @Param("money") BigDecimal money);

    boolean updateBeeCoinMoney(@Param("fee") BigDecimal fee, @Param("userId") String userId);

    boolean updateUserRechargeCardMoneyResource(@Param("userId") String userId, @Param("money") BigDecimal money);

    String queryAccountingPeriodId(@Param("orderId") String orderId);

    boolean updateOrderRefund(@Param("refundOrderId") String refundOrderId);

    boolean updateOrderTrade(@Param("refundOrderId") String refundOrderId);

    Integer updateReturnCash(@Param("param") RefundParamDTO refundPara);

    void updateDistributorReturn(@Param("param") RefundParamDTO refundPara);

    int updateRefundAccountPeriod(@Param("param") RefundAccountParamDTO param);

    AccountShopBillDetailsVO selectDetailsByPeriodId(@Param("accountingPeriodId") String accountingPeriodId);

    void editAccountStatus(@Param("accountingPeriodId") String accountingPeriodId, @Param("accountStatus") Integer accountStatus);

    AccountPeriodVO getAccountPeriodByIds(@Param("shopId") Integer shopId, @Param("userId") String userId);

    void updateAccountPeriod(@Param("param") AccountPeriodParamDTO param);

    BigDecimal querShopReturnCash(@Param("shopId") Integer shopId,@Param("pojo") ShopSalesStatisticsDTO pojo);

}
